Skip to content

Add TOTP authentication guide (#2196)#2226

Open
Thavamani13 wants to merge 1 commit into
grafana:mainfrom
Thavamani13:feat/totp-guide-2196
Open

Add TOTP authentication guide (#2196)#2226
Thavamani13 wants to merge 1 commit into
grafana:mainfrom
Thavamani13:feat/totp-guide-2196

Conversation

@Thavamani13

@Thavamani13 Thavamani13 commented Apr 26, 2026

Copy link
Copy Markdown

Summary

  • Adds a new totp-authentication.md guide under docs/sources/k6/next/examples/
  • Covers real-world use cases requested in issue Create a guide for how to use the TOTP library #2196: 2FA login flows, payment step-up authentication, secret source integration, time bias/token expiry handling, multi-account parameterization, and code verification
  • Links to existing totp jslib API reference and secret source docs throughout

Closes #2196

Test plan

  • All code examples use valid k6 APIs (k6/http, k6/secrets, k6/data) and the totp jslib
  • Frontmatter weight: 04 places the guide alongside other auth examples
  • <!-- md-k6:skip --> annotation added to the bash CLI snippet to skip k6 execution in CI
  • <K6_VERSION> placeholder used in all doc links (not hardcoded version strings)

@Thavamani13 Thavamani13 requested review from a team and heitortsergent as code owners April 26, 2026 03:38
@Thavamani13 Thavamani13 requested review from codebien and mstoykov and removed request for a team April 26, 2026 03:38
@cla-assistant

cla-assistant Bot commented Apr 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Apr 26, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Thavamani Murugan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Covers real-world use cases: basic 2FA login, payment step-up auth,
secret source integration, time bias/token expiry handling,
multi-account parameterization, and code verification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Thavamani13 Thavamani13 force-pushed the feat/totp-guide-2196 branch from e685e96 to 9bd4915 Compare April 26, 2026 03:39

@codebien codebien left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inancgumus as you developed the feature, can you review this guide, please?

@inancgumus inancgumus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! I'm reviewing this PR only from technicals. Some issues:

  • totp.gen(30, 30) generates the previous window's code. So, you'd need gen(30, -30) for the next window.
  • TOTP.verify() says "a code generated by the library is accepted by the server." But the TOTP library regenerates a code locally and compares strings. It doesn't talk to any server.
  • The "Before you begin" section says clock drift of more than 30 seconds will cause failures. Whether that's true depends on the server (many accept adjacent windows).

@codebien I've technically reviewed this. Can you check the writing please? Thanks.

@codebien codebien left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Thavamani13 I'll continue the review as soon as you've addressed @inancgumus's request, so feel free to re-request a review as soon as you've pushed changes.

@heitortsergent heitortsergent added the Area: OSS Content Improvements or additions to community/oss documentation label May 4, 2026
@mstoykov mstoykov removed their request for review May 14, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OSS Content Improvements or additions to community/oss documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a guide for how to use the TOTP library

4 participants